<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>获取Text和Html</title>
    <script type="text/javascript" src="JS/jquery-3.3.1.js"></script>
    <script>
    $(function(){
        var _str=$("#test");
        $("#btn1").click(function(){
            alert("Text："+_str.text());
        });

        $("#btn2").click(function(){
            alert("HTML："+_str.html());
        });

        $("#btn3").click(function(){
            alert("属性的值："+_str.attr("title"));
        });
    });
    </script>
</head>
<body>
    <p id="test" title="DOM操作">这是段落中的 <b>粗体</b> 文本。</p>
    <button id="btn1">显示文本</button>
    <button id="btn2">显示HTML</button>
    <button id="btn3">显示属性的值</button>
</body>
</html>